Iterator library

From Cppreference

< cpp
Jump to: navigation, search

Iterators are a generalization of pointers that allow C++ programs to access different containers in a uniform manner. Any algorithm that accepts iterators should accept regular pointers also.

Five iterator categories are defined, according to operations defined on them:

  • Input iterator
allows reading from the iterator object
allows iterating forward without multi-pass guarantee, i. e. reading the same element twice is not guaranteed to produce the same results
  • Output iterator
allows writing to the iterator object
allows iterating forward without multi-pass guarantee
  • Forward iterator
allows reading from the iterator object
allows iterating forward with multi-pass guarantee, i. e. reading the same element twice is guaranteed to produce the same results
  • Bidirectional iterator
allows reading from the iterator object
allows iterating forward and backward with multi-pass guarantee
  • Random access iterator
allows reading from the iterator object
allows iterating forward and backward randomly with multi-pass guarantee

Forward iterators satisfy the requirements of input iterators

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages